/*
 * @Author: Setsuna
 * @Email: 601890383@qq.com
 * @FilePath: \src\pages\CustomerManage\RightsAndInterests\component\RightsAndInterestsDetailDrawer.tsx
 * @Date: 2021-12-09 16:13:49
 * @LastEditTime: 2022-01-05 17:13:03
 */

import React from 'react'
import { http, UdForm } from '@/lib'
import { Select, Spin, Input } from 'antd'
import apis from '@/apis/CustomerManage'
import TextArea from 'antd/lib/input/TextArea'

export default class RightsAndInterestsDetailDrawer extends React.Component<any> {
  private labelCol: any = { span: 2 }
  protected recordDetailForm: any
  state = {
    loading: false,
    recordDetail: {},
  }
  render() {
    return (
      <Spin spinning={this.state.loading}>
        <UdForm
          labelCol={this.labelCol}
          getForm={form => (this.recordDetailForm = form)}
          values={this.state.recordDetail}
          items={[
            { id: 'brandName', label: '品牌公司', render: <Input readOnly={true} /> },
            { id: 'appraiseYear', label: '评级年度', render: <Input readOnly={true} /> },
            { id: 'customerCode', label: '客户编码', render: <Input readOnly={true} /> },
            { id: 'customerName', label: '客户名称', render: <Input readOnly={true} /> },
            { id: 'appraiseGrade', label: '等级', render: <Input readOnly={true} /> },
            { id: 'enjoyRightsStr', label: '权益项目', render: <Input readOnly={true} /> },
            // { id: 'ranking', label: '排名', render: <Input readOnly={true} /> },
            { id: 'remarks', label: '备注信息', render: <TextArea rows={3} readOnly={true} /> },
          ]}
        />
      </Spin>
    )
  }

  componentDidMount() {
    let { record } = this.props
    this.getDataDetail(record.id)
  }

  //获取等级权益详情
  private getDataDetail = (id: number | string) => {
    this.setState({ loading: true })
    http
      .get(apis.getRightsdetail, { params: { id } })
      .then(res => {
        let { data } = res
        this.setState({ recordDetail: data })
      })
      .finally(() => {
        this.setState({ loading: false })
      })
  }
}
